//import java.util.Random;


public class RandomSpeler implements Speler {
	
	public String naam;
	public int mark;
		
	public RandomSpeler(String n) {
		this.naam = n;
	}
	
	public RandomSpeler() {
		this.naam = "RandomSpeler";
	}
		
	public String getNaam() {
		return this.naam;
	}

	public int bepaalZet(Bord b) {
		int num = (int) (Math.round(Math.random()*8));
		//int num = ((int)Math.random())*9;
		//System.out.println(num);
		return num;
	}
	
	public int doeZet(Bord b) {
		int res = -1;
		if(b.doeZet(this, bepaalZet(b))) {
			res = 0;
		}
		else {
			boolean zetgelukt = false;
			while(!zetgelukt) {
				//System.out.println("Foutieve zet, probeer opnieuw");
				zetgelukt = b.doeZet(this,bepaalZet(b));
			} 
		}
		return res;
	}

}